import 'package:flutter/material.dart';
import 'package:flutter_learn/my_animated_button.dart';
import 'package:flutter_learn/overflow_page.dart';
import 'package:flutter_learn/pageview_page.dart';
import 'package:flutter_learn/recording_screen.dart';
import 'package:flutter_learn/sound.dart';
import 'package:flutter_learn/time_line_page.dart';
import 'package:super_tooltip/super_tooltip.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  SuperTooltipController controller = SuperTooltipController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SuperTooltip(
              arrowTipDistance: 30,
              arrowLength: 10,
              showBarrier: false,
              popupDirection: TooltipDirection.up,
              hasShadow: false,
              controller: controller,
              content: Container(
                height: 65,
                padding: const EdgeInsets.symmetric(horizontal: 8),
                child: const Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      textAlign: TextAlign.center,
                      "hello",
                      // overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                          fontSize: 25, fontWeight: FontWeight.bold),
                    ),
                    Padding(
                      padding: EdgeInsets.only(top: 2.0),
                      child: Row(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Text('/', style: TextStyle(fontSize: 11)),
                          Flexible(
                            child: Text(
                              "hello",
                              style: TextStyle(fontSize: 12),
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis, // 太长时隐藏溢出的部分
                            ),
                          ),
                          Text('/', style: TextStyle(fontSize: 11)),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
              child: const Text('super_tooltip'),
            ),
            ElevatedButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                        builder: (context) => const OverFlowPage()),
                  );
                },
                child: const Text("overflowBox")),
            ElevatedButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => RecordingScreen()),
                  );
                },
                child: const Text("record")),
            ElevatedButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => const Music()),
                  );
                },
                child: const Text("Music")),
            ElevatedButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => TimelineExample()),
                  );
                },
                child: const Text("time line")),
            ElevatedButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                        builder: (context) => const PageViewTest()),
                  );
                },
                child: const Text("page view")),
            AnimatedButton(onPressed: () {}, child: const Text("hello")),
          ],
        ),
      ),
    );
  }
}
